package com.maodou.core.network

sealed class NetworkError(open val cause: Throwable? = null) {
    data class Http(val code: Int, val message: String?, val body: String? = null, override val cause: Throwable? = null) : NetworkError(cause)
    data class Network(override val cause: Throwable) : NetworkError(cause)
    data class Serialization(override val cause: Throwable) : NetworkError(cause)
    // 业务错误（HTTP 200 但后端 code/success 标识失败）
    data class Business(val code: String?, val message: String?, val raw: String? = null) : NetworkError(null)
    data class Unknown(override val cause: Throwable?) : NetworkError(cause)
}

sealed class NetworkResult<out T> {
    data class Success<T>(val data: T) : NetworkResult<T>()
    data class Failure(val error: NetworkError) : NetworkResult<Nothing>()
}